define(()=>{
    return function(goodsMsg,res){
        
        $(".spcar").on("click",".scsj",function(){
             
            const id =  $(this).parent().parent().attr("index");
              let i = 0;
              
            goodsMsg.some((val,idx)=>{
              i=idx;
             return val.id===id
            });
              goodsMsg.splice(i,1)
       localStorage.setItem("goodsMsg",JSON.stringify(goodsMsg));
       let ap = goodsMsg.reduce((start,val)=>val.flag?start+=val.num*val.price:start,0)
        $(".allprice").html(ap);

        console.log("66");
              
        let str="";
        res.forEach( val1=>{
         
                      goodsMsg.forEach(val2=>{ 
                       //  console.log("1");
                          if(val1.goodsId===val2.id){
                           //  console.log("888");
                            str+=`     
                            <tr  index="${val1.goodsId}">
                                
                            <td  height="50px"><input type="checkbox"${val2.flag?"checked":"" } class="fxk"> </td>
                                <td width="100" height="50px"></td>
                                <td width="200"  align="left"><img src="${val1.proImg}" alt="" class="bgtp">${val1.proName}</td>
                                <td width="100" align="center">皮肤</td>
                                <td width="120">${val1.qb}Q币</td>
                                <td width="100">永久</td>
                                <td width="100"><input type="number" value="${val2.num}" class="setNum" width="20px"></td>
                                <td width="94">无优惠</td>
                                <td width="146" class="sall">${val1.qb*val2.num}Q币</td>
                                <td width="136"><a href="">关注</a><span class="scsj">删除</span></td>
                            </tr> `
                              
                          }
                      }
     
                      )
                      let apgwc = goodsMsg.reduce((start,val)=>val.flag?start+=val.num:start,0);
                      console.log(apgwc);
                      // let apgwcc="购物车 （"+apgwc+"）";
                      $(".gwccc").html(apgwc);
                        
        })
            $(".spcar").html(str);
            if($('.allprice').text()==0){
          
              $(".tjan").css("background","#666");
              
             
             }else{
               $(".tjan").css("background","red") 
             
             }
    

       
             });
    
            //  xrcar(goodsMsg,res)
    }
});